﻿// See https://aka.ms/new-console-template for more information
using DataService.Core.Json;
using DataService.Office.Excel;
using DataService.Office.WordDTO;
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Drawing;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Spreadsheet;
using DocumentFormat.OpenXml.Wordprocessing;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using TestOffice;





//TestWord.SY_4(@"新建 DOCX 文档.docx");
TestWord.TestOutputWord(@"C:\Users\dell\Desktop\新建文件夹\ddddddddddddd.docx");
Console.WriteLine("测试推送");
Console.WriteLine("完成");
return;

//var datas=ExcelHepler.ImportExcel(@"D:\xxxxx.xlsx");
//return;

//using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(@"D:\xxxxx.xlsx", false))
//{
//    DocumentFormat.OpenXml.Packaging.WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;


//    IEnumerable<Sheet> sheets = spreadsheetDocument.WorkbookPart.Workbook.GetFirstChild<Sheets>().Elements<Sheet>();
//    foreach (Sheet sheet in sheets)
//    {
//        string sheetName = sheet.Name; // 假设我们只处理第一个工作表

//        WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById(sheet.Id);
//        Worksheet workSheet = worksheetPart.Worksheet;
//        var sheetData = workSheet.GetFirstChild<DocumentFormat.OpenXml.Spreadsheet.SheetData>();

//        SharedStringTable stringTable = workbookPart.SharedStringTablePart.SharedStringTable;

//        int rowIndex = 0;
//        foreach (Row r in sheetData.Elements<Row>())
//        {

//            rowIndex++;
//            if ((sheetName == "科技1" && rowIndex == 80) || (sheetName == "科技2" && rowIndex == 67))
//            {
//                var dddd = r.Descendants<Cell>();
//                Console.WriteLine(dddd.Count());

//                foreach (Cell c in r.Elements<Cell>())
//                {
//                    string cellValue = ExcelHepler.GetCellValue(c, workbookPart, stringTable);
//                    Console.WriteLine($"Row: {r.RowIndex}, Column:{c.CellReference}, Value: {cellValue}");
//                }
//            }

//        }
//    }





//    var excelCellInfos = ExcelHepler.GetExcelSheets(workbookPart);
//    foreach (var item in excelCellInfos)
//    {
//        DocumentFormat.OpenXml.Spreadsheet.Sheet sheet = ExcelHepler.SeekSheet(workbookPart, item.SheetName);

//        WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById(sheet.Id);
//        DocumentFormat.OpenXml.Spreadsheet.Worksheet worksheet = worksheetPart.Worksheet;
//        var list111 = ExcelHepler.GetMergeCells(worksheet);
//        foreach (var temp in list111)
//        {
//            Console.WriteLine($"{item.SheetName}->>>{temp.CellPostion}");
//            ExcelHepler.CellReferenceToRowAndColumn(temp.CellPostion.Split(":")[0], out int row, out int col);
//            Console.WriteLine($"第{row}行，第{col}列");
//        }




//    }

//}
//Console.WriteLine("完成");
//return;

//using (SpreadsheetDocument spreadsheetDocument = SpreadsheetDocument.Open(@"D:\xxxxx.xlsx", false))
//{
//    DocumentFormat.OpenXml.Packaging.WorkbookPart workbookPart = spreadsheetDocument.WorkbookPart;


//    DocumentFormat.OpenXml.Spreadsheet.CellFormats cellFormats = ExcelHepler.GetCellFormat(workbookPart);
//    DocumentFormat.OpenXml.Spreadsheet.Stylesheet stylesheet = ExcelHepler.GetStylesheet(workbookPart);
//    ThemePart themePart = workbookPart.ThemePart;
//    //uint cellStyleIndex = sheetCell.StyleIndex?.Value ?? 0;

//    DocumentFormat.OpenXml.Spreadsheet.Sheet sheet = ExcelHepler.SeekSheet(workbookPart, "科技2");



//    WorksheetPart worksheetPart = (WorksheetPart)workbookPart.GetPartById(sheet.Id);
//    DocumentFormat.OpenXml.Spreadsheet.Worksheet worksheet = worksheetPart.Worksheet;
//    var list111 = ExcelHepler.GetMergeCells(worksheet);

//    int num = 0;
//    foreach (DocumentFormat.OpenXml.Spreadsheet.Row sheetRow in worksheet.Descendants<DocumentFormat.OpenXml.Spreadsheet.Row>())
//    {
//        num++;
//        if (num == 56)
//        {

//        }
//        foreach (DocumentFormat.OpenXml.Spreadsheet.Cell sheetCell in sheetRow.Elements<DocumentFormat.OpenXml.Spreadsheet.Cell>())
//        {
//            var cellStyleDTO = ExcelHepler.GetCellFont(cellFormats, stylesheet, themePart, sheetCell);
//        }
//    }


//}

//return;

DataService.Office.WordMain.IXmlPackageBussiness xmlPackageBussiness = new DataService.Office.WordMain.XmlPackageBussiness();



//Console.WriteLine("Hello, World!");






//string input = "The price is 100 dollars and 200 A12B13T4cents.";
//string pattern = @"\d+";

//string result = Regex.Replace(input, pattern, string.Empty);
//Console.WriteLine(result);
//return;

//string wordPath = @"D:\888888888888.docx";
//string excelPath = @"D:\材料表 - 副本 - 副本 (2).xlsx";

